﻿@model dynamic

@{
    ViewBag.Title = "入区诊断";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<form id="form1">
    <div class="panel-default" style="padding-right:10px;">
        <table class="form">
            <tr>
                <th class="formTitle"><span class="required">*</span>诊断1：</th>
                <td class="formValue">
                    <input id="ryzdmc1" attr-zddm="" attr-ICD10="" name="ryzdmc1" type="text" class="form-control required" autocomplete="off" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">诊断2：</th>
                <td class="formValue">
                    <input id="ryzdmc2" attr-zddm="" attr-ICD10="" name="ryzdmc2" type="text" class="form-control" autocomplete="off" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">诊断3：</th>
                <td class="formValue">
                    <input id="ryzdmc3" attr-zddm="" attr-ICD10="" name="ryzdmc3" type="text" class="form-control" autocomplete="off" />
                </td>
            </tr>
        </table>
    </div>
</form>
<script lang="javascript">
    var ybnhlx = "";
    var brxz = '@ViewBag.brxz';
    if (brxz=="1") {
        ybnhlx = "yb";
    }
    if (brxz == "8") {
        ybnhlx = "nh";
    }
    $(function () {

        $.najax({
            type: "GET",
            url: "/NurseManage/WardMaintenance/GetPatRyDiagnosis?r=" + Math.random(),
            data: { zyh: '@ViewBag.zyh' },
            loadingtext: "数据加载中，请稍后...",
            dataType: "json",
            success: function(zdlist) {
                $.each(zdlist, function (n, item) {
                    switch (item.zdpx) {
                    case "1":
                        $("#ryzdmc1").val(item.zdmc).attr("attr-zddm", item.zdCode).attr("attr-ICD10", item.icd10);
                        break;
                    case "2":
                        $("#ryzdmc2").val(item.zdmc).attr("attr-zddm", item.zdCode).attr("attr-ICD10", item.icd10);
                        break;
                    case "3":
                        $("#ryzdmc3").val(item.zdmc).attr("attr-zddm", item.zdCode).attr("attr-ICD10", item.icd10);
                        break;
                    default:
                        break;
                    }
                });
            }
        });
    });

    $("#ryzdmc1").newtouchBatchFloatingSelector({
        height: 200,
        width: 600,
        clickautotrigger: true,
        url: "/NurseManage/WardMaintenance/GetryzdSelect",
        ajaxparameters: function () {
            return "ryzd=" + $("#ryzdmc1").val() + "&ybnhlx=" + ybnhlx;
        },
        caption: "入院诊断",
        colModel: [
            { label: '名称', name: 'zdmc', widthratio: 60 },
            { label: '拼音', name: 'py', widthratio: 20 },
            { label: 'icd10', name: 'icd10', widthratio: 20 },
            { label: '编号', name: 'zdbh', hidden: true },
            { label: '内码', name: 'zdnm', hidden: true }
        ],
        itemdbclickhandler: function ($this) {
            $("#ryzdmc1").val($this.attr('data-zdmc')).attr("attr-zddm", $this.attr('data-zdbh')).attr("attr-ICD10", $this.attr('data-icd10'));
        }
    });
    $("#ryzdmc2").zdFloatingSelector({
        height: 200,
        width: 600,
        clickautotrigger: true,
        url: "/NurseManage/WardMaintenance/GetryzdSelect",
        ajaxparameters: function () {
            return "ryzd=" + $("#ryzdmc2").val() + "&ybnhlx=" + ybnhlx;
        },
        caption: "入院诊断",
        colModel: [
            { label: '名称', name: 'zdmc', widthratio: 60 },
            { label: '拼音', name: 'py', widthratio: 20 },
            { label: 'icd10', name: 'icd10', widthratio: 20 },
            { label: '编号', name: 'zdbh', hidden: true },
            { label: '内码', name: 'zdnm', hidden: true }
        ],
        itemdbclickhandler: function ($this) {
            $("#ryzdmc2").val($this.attr('data-zdmc')).attr("attr-zddm", $this.attr('data-zdbh')).attr("attr-ICD10", $this.attr('data-icd10'));
        }
    });
    $("#ryzdmc3").zdFloatingSelector({
        height: 200,
        width: 600,
        clickautotrigger: true,
        url: "/NurseManage/WardMaintenance/GetryzdSelect",
        ajaxparameters: function () {
            return "ryzd=" + $("#ryzdmc3").val() + "&ybnhlx=" + ybnhlx;
        },
        caption: "入院诊断",
        colModel: [
            { label: '名称', name: 'zdmc', widthratio: 60 },
            { label: '拼音', name: 'py', widthratio: 20 },
            { label: 'icd10', name: 'icd10', widthratio: 20 },
            { label: '编号', name: 'zdbh', hidden: true },
            { label: '内码', name: 'zdnm', hidden: true }
        ],
        itemdbclickhandler: function ($this) {
            $("#ryzdmc3").val($this.attr('data-zdmc')).attr("attr-zddm", $this.attr('data-zdbh')).attr("attr-ICD10", $this.attr('data-icd10'));
        }
    });

    //backspance事件绑定
    $("#ryzdmc1").keyup(function (event) {
        if (event.keyCode === 8) {
            $("#ryzdmc1").val("").attr("attr-zddm", "").attr("attr-ICD10", "");
        }
    });
    //backspance事件绑定
    $("#ryzdmc2").keyup(function (event) {
        if (event.keyCode === 8) {
            $("#ryzdmc2").val("").attr("attr-zddm", "").attr("attr-ICD10", "");
        }
    });
    //backspance事件绑定
    $("#ryzdmc3").keyup(function (event) {
        if (event.keyCode === 8) {
            $("#ryzdmc3").val("").attr("attr-zddm", "").attr("attr-ICD10", "");
        }
    });
    //保存入院诊断
    function SavaInArea() {
        if ($("#ryzdmc1").val() === "" || $("#ryzdmc1").attr("attr-zddm") === "") {
            $.modalAlert('入院诊断1不能为空！', 'warning');
            return;
        }
        var patInAreaVo = {
            zyh: "@ViewBag.zyh",
            ryzdmc1: $("#ryzdmc1").val(),
            ryzddm1: $("#ryzdmc1").attr("attr-zddm"),
            ryzdICD101: $("#ryzdmc1").attr("attr-ICD10"),
            ryzdmc2: $("#ryzdmc2").val(),
            ryzddm2: $("#ryzdmc2").attr("attr-zddm"),
            ryzdICD102: $("#ryzdmc2").attr("attr-ICD10"),
            ryzdmc3: $("#ryzdmc3").val(),
            ryzddm3: $("#ryzdmc3").attr("attr-zddm"),
            ryzdICD103: $("#ryzdmc3").attr("attr-ICD10")
        };

        $.najax({
            type: "POST",
            url: "/NurseManage/WardMaintenance/SavaInPatDiagnosis",
            data: { patInAreaVo: patInAreaVo },
            dataType: "json",
            async: false,
            success: function () {
                if (ajaxresp.state==="success") {
                    $.modalMsg('保存成功', 'success');
                }
                else {
                    $.modalAlert(ajaxresp.message, 'warning');
                }
            }
        });
    }
</script>